From 368fba70bbecf200f2190fbbadad5ebe1c8570d6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Tue, 30 Aug 2005 12:49:55 +0000 Subject: [PATCH] fixed problems shown by tests/model.c --- ChangeLog | 9 +++ babl/base/model-gray.c | 4 +- extensions/Makefile.in | 5 +- extensions/naive-CMYK.c | 124 ++++++++++++++++++++++------------------ 4 files changed, 82 insertions(+), 60 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9c5df22..aeb9fd2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-08-30 Øyvind Kolås + + * babl/base/model-gray.c: + (rgba_to_gray_alpha_premultiplied): fixed array index error. + * extensions/Makefile.in: Added -I../babl to include path. + * extensions/naive-CMYK.c: (init), (rgb_to_cmyk), (cmyk_to_rgb): + reordered the code, fixed a component swapping issue + discovered by tests/model.c + 2005-08-30 Øyvind Kolås * tests/srgb_to_lab_u8.c: updated values. diff --git a/babl/base/model-gray.c b/babl/base/model-gray.c index d8097bd..b494dea 100644 --- a/babl/base/model-gray.c +++ b/babl/base/model-gray.c @@ -255,7 +255,7 @@ gray_alpha_premultiplied_to_rgba (int src_bands, double luminance = *(double *)src[0]; double alpha = *(double *)src[1]; - if (alpha > 0.001) + if (alpha > 0.00001) { luminance = luminance / alpha; } @@ -301,7 +301,7 @@ rgba_to_gray_alpha_premultiplied (int src_bands, luminance *= alpha; *(double*)dst[0] = luminance; - *(double*)dst[2] = alpha; + *(double*)dst[1] = alpha; BABL_PLANAR_STEP } } diff --git a/extensions/Makefile.in b/extensions/Makefile.in index 40c798f..cb4bb42 100644 --- a/extensions/Makefile.in +++ b/extensions/Makefile.in @@ -6,7 +6,6 @@ SOBJS = $(CFILES:.c=.so) all: $(SOBJS) - %.so: %.c $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< @@ -21,13 +20,13 @@ CIE-Lab.so: CIE-Lab.c - ############################################################################# ############################################################################# CFLAGS = -O2 -Wall LDFLAGS = -shared -lc -CFLAGS += `pkg-config babl --cflags` +CFLAGS += -I../babl +#`pkg-config babl --cflags` #LDFLAGS += `pkg-config babl --libs` diff --git a/extensions/naive-CMYK.c b/extensions/naive-CMYK.c index b69ce38..2eb39e6 100644 --- a/extensions/naive-CMYK.c +++ b/extensions/naive-CMYK.c @@ -23,34 +23,29 @@ #include "babl.h" #include "util.h" -static void components (void); -static void models (void); -static void conversions (void); -static void formats (void); - +static void rgb_to_cmyk (int src_bands, + void **src, + int *src_pitch, + int dst_bands, + void **dst, + int *dst_pitch, + int n); +static void cmyk_to_rgb (int src_bands, + void **src, + int *src_pitch, + int dst_bands, + void **dst, + int *dst_pitch, + int n); int init (void) { - components (); - models (); - conversions (); - formats (); - - return 0; -} -static void -components (void) -{ babl_component_new ("cyan", NULL); babl_component_new ("yellow", NULL); babl_component_new ("magenta", NULL); babl_component_new ("key", NULL); -} -static void -models (void) -{ babl_model_new ( "name", "CMYK", babl_component ("cyan"), @@ -59,6 +54,58 @@ models (void) babl_component ("key"), NULL ); + + babl_model_new ( + "name", "CMYKA", + babl_component ("cyan"), + babl_component ("magenta"), + babl_component ("yellow"), + babl_component ("key"), + babl_component ("A"), + NULL + ); + + babl_conversion_new ( + babl_model ("RGBA"), + babl_model ("CMYK"), + "planar", rgb_to_cmyk, + NULL + ); + + babl_conversion_new ( + babl_model ("CMYK"), + babl_model ("RGBA"), + "planar", cmyk_to_rgb, + NULL + ); + + + babl_conversion_new ( + babl_model ("RGBA"), + babl_model ("CMYKA"), + "planar", rgb_to_cmyk, + NULL + ); + + babl_conversion_new ( + babl_model ("CMYKA"), + babl_model ("RGBA"), + "planar", cmyk_to_rgb, + NULL + ); + + babl_format_new ( + "name", "CMYK float", + babl_model ("CMYK"), + babl_type ("float"), + babl_component ("cyan"), + babl_component ("yellow"), + babl_component ("magenta"), + babl_component ("key"), + NULL + ); + + return 0; } static void @@ -80,7 +127,7 @@ rgb_to_cmyk (int src_bands, double cyan, magenta, yellow, key; - double pullout = 1.0; + double pullout = 0.8; cyan = 1.0 - red; magenta = 1.0 - green; @@ -132,8 +179,8 @@ cmyk_to_rgb (int src_bands, while (n--) { double cyan = *(double*)src[0]; - double yellow = *(double*)src[1]; - double magenta = *(double*)src[2]; + double magenta = *(double*)src[1]; + double yellow = *(double*)src[2]; double key = *(double*)src[3]; double red, green, blue; @@ -164,36 +211,3 @@ cmyk_to_rgb (int src_bands, } } -static void -conversions (void) -{ - babl_conversion_new ( - babl_model ("RGBA"), - babl_model ("CMYK"), - "planar", rgb_to_cmyk, - NULL - ); - - - babl_conversion_new ( - babl_model ("CMYK"), - babl_model ("RGBA"), - "planar", cmyk_to_rgb, - NULL - ); -} - -static void -formats (void) -{ - babl_format_new ( - "name", "CMYK float", - babl_model ("CMYK"), - babl_type ("float"), - babl_component ("cyan"), - babl_component ("yellow"), - babl_component ("magenta"), - babl_component ("key"), - NULL - ); -} -- 2.30.2